package com.svmc.app.task.adapter;

import java.util.ArrayList;

import com.svmc.app.task.activity.R;
import com.svmc.app.task.adapter.ListAdapter.ViewHolder;
import com.svmc.app.task.model.HelpModel;
import com.svmc.app.task.model.TaskModel;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ListHelpAdapter extends BaseAdapter {
	Context mcontext;
	ArrayList<HelpModel> listHelp = new ArrayList<HelpModel>();
	private LayoutInflater mInflater;
	DbAdapter db;
    public ListHelpAdapter(Context context, ArrayList<HelpModel> help) {
    	mcontext = context;
    	listHelp = help;
    	mInflater = LayoutInflater.from(context);
    	db = new DbAdapter(context);
    }

	@Override
	public int getCount() {
		
		return listHelp.size();
	}

	@Override
	public Object getItem(int position) {
		
		return listHelp.get(position);
	}

	@Override
	public long getItemId(int position) {
		
		return position;
	}

	@Override
	public View getView(int position, View view, ViewGroup parentview) {
		HolderViewHelp holder;
		if(view==null){
			mInflater = (LayoutInflater) mcontext
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			view = mInflater.inflate(R.layout.item_help, null);
			holder = new HolderViewHelp();
			holder.thumbnail =(ImageView)view.findViewById(R.id.item_help_img_thumbnail);
			holder.nameHelp =(TextView)view.findViewById(R.id.item_help_txt_name);
			view.setTag(holder);
		}else {
			holder =(HolderViewHelp)view.getTag();
		}
		
		holder.nameHelp.setText(listHelp.get(position).getNameTip());
		if(listHelp.get(position).getNameTip().equalsIgnoreCase(mcontext.getString(R.string.help_menu_funtion_base))){
			holder.thumbnail.setImageResource(R.drawable.icon_funtion);
		}else if (listHelp.get(position).getNameTip().equalsIgnoreCase(mcontext.getString(R.string.help_menu_setting_application))) {
			holder.thumbnail.setImageResource(R.drawable.icon_setting);
		}else if (listHelp.get(position).getNameTip().equalsIgnoreCase(mcontext.getString(R.string.help_menu_author)) ){
			holder.thumbnail.setImageResource(R.drawable.icon_author);	
		}
		return view;
	}
	static class HolderViewHelp{
		ImageView thumbnail;
		TextView nameHelp;
	}

}
